package com.yuwj.chinaa.activity;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yuwj.chinaa.R;
import com.yuwj.chinaa.base.BaseActivity;
import com.yuwj.chinaa.entity.EntityBurseRecord;
import com.yuwj.chinaa.entity.EntityBurseRecordDetail;
import com.yuwj.chinaa.presenter.IPresenter;
import com.yuwj.chinaa.presenter.presenterImpl.PresenterImpl;
import com.yuwj.chinaa.util.ToastUtil;

import org.json.JSONException;
import org.json.JSONObject;

import butterknife.BindView;

//钱包记录详情界面
public class AssetsBurseDetailActivity extends BaseActivity{
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_chinaa_count)
    TextView tvCoinCount;
    @BindView(R.id.tv_remittance_user)
    TextView tvRemittanceUser;
    @BindView(R.id.tv_gathering_user)
    TextView tvGatherUser;
    @BindView(R.id.tv_kuangg_fee)
    TextView tvKuanggFee;
    @BindView(R.id.tv_remark)
    TextView tvRemark;
    @BindView(R.id.tv_order_no)
    TextView tvOrderNo;
    @BindView(R.id.tv_order_time)
    TextView tvOrderTime;

    IPresenter presenter;
    EntityBurseRecord entityBurseRecord;
    EntityBurseRecordDetail entityBurseRecordDetail;


    @Override
    public int setCustomContentViewResourceId() {
        return R.layout.activity_assets_burse_detail;
    }

    public static Intent createIntent(Context context, EntityBurseRecord entityBurseRecord) {
        Intent intent= new Intent(context, AssetsBurseDetailActivity.class);
        intent.putExtra("entityBurseRecord",entityBurseRecord);
        return intent;
    }

    @Override
    public void initParam() {
        presenter=new PresenterImpl(this);
        entityBurseRecord=(EntityBurseRecord) getIntent().getSerializableExtra("entityBurseRecord");

    }

    @Override
    public void initView() {
        if (entityBurseRecordDetail!=null){
            tvCoinCount.setText(entityBurseRecordDetail.getChinaANumber()+"  china-A");
            tvRemittanceUser.setText(entityBurseRecordDetail.getRemittanceUser());
            tvGatherUser.setText(entityBurseRecordDetail.getGatheringUser());
            tvKuanggFee.setText(entityBurseRecordDetail.getServiceCharge()+"  china-A");
            tvRemark.setText(entityBurseRecordDetail.getRemark());
            tvOrderNo.setText(entityBurseRecordDetail.getOrderCode());
            tvOrderTime.setText(entityBurseRecordDetail.getCreateTime());
        }
        tvTitle.setText("记录详情");
        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    public void initOperator() {
        JSONObject param=new JSONObject();
        try {
            param.put("burseid",entityBurseRecord.getId()+"");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        presenter.getUserBurseDetail(param.toString());

    }


    @Override
    public void onGetUserBurseDetailSuccess(EntityBurseRecordDetail entityBurseRecordDetail) {
        super.onGetUserBurseDetailSuccess(entityBurseRecordDetail);
        this.entityBurseRecordDetail=entityBurseRecordDetail;
        initView();
    }

    @Override
    public void onGetUserBurseDetailFail(Exception e) {
        super.onGetUserBurseDetailFail(e);
        ToastUtil.getInstance().shortLength(context,e.getMessage());
    }
}
